package visualizer;

import java.util.ArrayList;

public class Edge {

	private String id;
	private String src;
	private String dest;
	private String srcFieldname;
	private String srcShortFieldname;
	private ArrayList<String> orderIDs;
	private boolean deleted;
	private Node srcNode;
	private String colorField;
	
	public Edge() {
		this.orderIDs = new ArrayList<String>();
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getDest() {
		return dest;
	}
	public void setDest(String dest) {
		this.dest = dest;
	}
	public String getSrcFieldname() {
		return srcFieldname;
	}
	public void setSrcFieldname(String srcField) {
		this.srcFieldname = srcField;
		this.srcShortFieldname = srcFieldname.substring(srcFieldname.lastIndexOf('.')+1);
	}
	public String getSrcShortFieldname() {
		return srcShortFieldname;
	}
	
	public ArrayList<String> getOrderIDs() {
		return this.orderIDs;
	}
	public void setOrderIDs(ArrayList<String> list) {
		this.orderIDs = list;
	}
	public void addOrderID(String s) {
		this.orderIDs.add(s);
	}
	public String getSrc() {
		return src;
	}
	public void setSrc(String src) {
		this.src = src;
	}
	public boolean hasOrderID(String orderID) {
		return orderIDs.contains(orderID);
	}
	public boolean isDeleted() {
		return this.deleted;
	}
	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	public Node getSrcNode() {
		return this.srcNode;
	}
	public void setSrcNode(Node srcNode) {
		this.srcNode = srcNode;
	}
	public String getColorField() {
		return colorField;
	}

	public void setColorField(String colorField) {
		this.colorField = colorField;
	}

	public String toString() {
		String s = "";
		s += getClass()+System.getProperty("line.separator");
		s += "Id: " + this.getId()+System.getProperty("line.separator");
		s += "Src: " + this.getSrc()+System.getProperty("line.separator");
		s += "Dest: " + this.getDest()+System.getProperty("line.separator");
		s += "SrcFieldname: " + this.getSrcShortFieldname() +" ("+ this.getSrcFieldname()+")"+System.getProperty("line.separator");
		s += "Lines:";
		for(String lines: getOrderIDs()) {
			s += " " +lines;
		}
		s += System.getProperty("line.separator");
		return s;
	}
	@Override
	public boolean equals(Object object) {
		if(object instanceof Edge) {
			return equals((Edge)object);
		}
		else {
			return super.equals(object);
		}
	}
	public boolean equals(Edge edge) {
		return edge.getId().equals(this.getId());
	}
}
